<template>
	<view class="all-box containers">
		<view class="img">
			<image :src="OSS_HOST+'img/demo-head.png'"></image>
		</view>
		<view class="content">
			<view class="nameT">
				成员名称
			</view>
			<view class="xingm">
				
				<input type="text" v-model="list.nickname"  placeholder="请输入名称">
			</view>
		</view>
		<view class="content">
			<view class="nameT">
				手机号码
			</view>
			<view class="xingm">
				{{list.tel}}
			</view>
		</view>
		
		<view class="content">
			<view class="nameT">
				入职日期
			</view>
			<view class="xingm">
				{{list.create_time}}
			</view>
		</view>
		<view class="content" v-if="level == 0">
			<view class="nameT">
				 角色
			</view>
			<view class="xingm">
				<view @tap.stop="checkLevel(1)"><text class="iconfont" :style="list.level==1?'color:#f44336':''">{{list.level==1?'&#xe646;':'&#xe638;'}}</text> 区域代理 </view>
				<view @tap.stop="checkLevel(2)"><text class="iconfont" :style="list.level==2?'color:#f44336':''">{{list.level==2?'&#xe646;':'&#xe638;'}}</text> 推广员 </view>
			</view>
		</view>

		<view class="btn_delete" style="margin-top: 90rpx;" @click="deleteUser">
			<image style="width: 48rpx;
height: 48rpx;margin-right: 16rpx;" :src="OSS_HOST+'img/demo-head.png'"></image>
			删除成员
		</view>
		<view class="btn_delete" style="margin-top: 90rpx;" @click="saveUser">
					
					保存信息
				</view>

		<tuiTips ref="toast"></tuiTips>
		<!-- <New_personnel ref="personnel"></New_personnel> -->
		<uni-popup ref="buyerModel" type="center" custom="true">
			<view class="vipCard-box" @tap.stop="toVipCard()">
				<view class="img">
					<image :src="OSS_HOST+'img/demo-del.png'" mode="aspectFill"></image>
				</view>
			</view>
		</uni-popup>

		<uni-popup ref="inputDialog" type="dialog">
			<view class="Dmk" style="background-color: #fff;">
				<view class="Cy">
					确定删除该成员？
				</view>
				<view class="btn">
					<view @click="this.$refs.inputDialog.close()">
						取消
					</view>
					<view class="" style=" color: #576b95;" @click="YEs">
						确定
					</view>
				</view>
			</view>

		</uni-popup>

	</view>
</template>
<script>
	// 骨架屏
	import tuiSkeleton from "@/components/tui-skeleton/tui-skeleton"
	// 气泡框
	// import bubblePopup from '@/components/tui-bubble-popup/tui-bubble-popup.vue'
	// 引入最下面的线
	// import tuiDivider from "@/components/divider/divider.vue"
	//下拉组件
	// import uniLoadMore from '@/components/uni-load-more.vue';
	// import tuiListCell from "@/components/list-cell/list-cell"
	// import uniPopup from '@/components/uni-popup/uni-popup.vue'
	// import tuiButton from '@/components/button/button.vue'
	// import hxNavbar from '@/components/hx-navbar/hx-navbar'
	// import New_personnel from "@/components/Newmessage/New_personnel"
	import Vue from 'vue'
	import jsCookies from '@/node_modules/js-cookie'
	import store from '@/store/index.js';
	import {
		oss_host
	} from '@/config/config.js';
	// 公共底部
	// import btabbar from '@/components/indexBottomTable/bottomtabbar.vue'
	import uniPopup from '@/components/uni-popup/uni-popup.vue'
	import {
		mapGetters
	} from 'vuex';

	// 按需加载
	export default {


		components: {
			// tuiModal,
			uniPopup,
			// btabbar,
			// tuiListCell,
			// tuiDivider,
			// uniLoadMore,
			// tuiButton,
			// bubblePopup,
			// tuiSkeleton,
			// New_personnel
		},
		data() {
			return {

				isTop: 0,
				navConfig: {
					// business-enter-nav.png
					backgroundImg: 'https://xoimg.aiouning.com/static/img/business-enter-nav.png',
					// title:'申请列表',
					color: '#fff',
					fontSize: 12,
					back: true,
					height: 55


				},

				// 图片链接站点
				OSS_HOST: oss_host,
				contentText: {
					contentdown: '上拉显示更多',
					contentrefresh: '正在加载...',
					contentnomore: '没有更多数据了',
					contentfirst: "暂无数据"
				},
				reason: '',
				check_estate: false,
				id: '',
				level:1,


				message: "",

				//接口数据
				data: {

					list: []


				},

				cartsListHeight: 400, //动态高度
				calcullateHeight: 400, //固定高度，计算需要
				current: 0,


				curr_page: 0,
				last_page: 0,


				// 骨架屏
				skeletonShow: true,
				list: null
			}
		},

		computed: {
			//注册网络状态
			...mapGetters(['netWorkType', 'loginStatus'])
		},
		onPageScroll: function(e) {

			if (e.scrollTop > 300) {
				this.isTop = 1
			} else {
				this.isTop = 0
			}
		},
		onLoad: function(e) {
			this.list = JSON.parse(decodeURIComponent(e.itemlist));
			console.log('123', this.list)
			this.level = e.level


			let that = this;

			//that.$refs.popupvLogin.open()
			//  高度自适应
			uni.getSystemInfo({
				success: function(res) {
					// console.log(res)
					let calc = res.windowHeight;
					that.winHeight = calc;
				}
			});
			//#ifdef  MP-WEIXIN
			that.navHeight = 44;
			//#endif

		},
		//页面初始
		onShow() {
			this.curr_page = 0
			this.getList()



		},

		onPullDownRefresh: function() {
			//下拉刷新的时候请求一次数据
			//console.log(11)
			this.curr_page = 0
			// this.loadingType = 3;				
			// this.getList();


		},
		onReachBottom: function() {
			//触底的时候请求数据，即为上拉加载更多
			//为了更加清楚的看到效果，添加了定时器
			//console.log(this.curr_page)

			if (this.curr_page >= this.last_page) {
				uni.showToast({
					icon: 'none',
					title: '没有更多数据'
				});

				// this.loadingType = 2;				
				return;
			}

			this.loadingType = 1;
			// 正常应为:
			// this.articleList();
		},

		methods: {

			deleteUser() {
				this.$refs.inputDialog.open()
			},
			YEs() {
				this.$refs.inputDialog.close()
				

				this.deleteFc()


			},

			dialogInputConfirm() {},

			refresh() {
				this.getList()
			},
			getList() {
				const _this = this
				//提交ajax
				// console.log(1111)
				var opt = {
					url: '/User/businessInfoList',
					data: {
						page: _this.curr_page + 1
					},
					success: function(res) {
						if (res.status == 1) {
							_this.data.list = res.data.list

						} else {


						}

					}
				};
				this.$service.GetApi(opt) //网络	

			},
			checkLevel(level){
				this.list.level = level
			},
			saveUser(){
				let _this = this
				var opt = {
					url: '/assert/editEnter',
					data: {
						id: this.list.id,
						user_id: this.list.user_id,
						level:_this.list.level,
						nickname:_this.list.nickname
					},
					success: function(res) {
						
						if (res.status == 1) {
							wx.showToast({
								icon:'none',
								title:'操作成功'
							})
							setTimeout(() => {
								uni.navigateBack();
							}, 1500)
				
						} else {
							let options = {
								msg: '操作失败',
								type: 'danger'
							};
							_this.$refs.toast.showTips(options);
				
						}
				
					},
				
					
				};
				this.$service.GetApi(opt) //网络	
			},
			deleteFc() {
				const _this = this
				//提交ajax
				// console.log(1111)
				var opt = {
					url: '/assert/assertDel',
					data: {
						id: this.list.id,
						user_id: this.list.user_id
					},
					success: function(res) {
						
						if (res.status == 1) {
							_this.$refs.buyerModel.open()
							setTimeout(() => {
								_this.$refs.buyerModel.close()
							}, 1000)
							setTimeout(() => {
								uni.navigateBack();
							}, 1500)

						} else {
							let options = {
								msg: '删除失败',
								type: 'danger'
							};
							_this.$refs.toast.showTips(options);

						}

					},

					
				};
				this.$service.GetApi(opt) //网络	

			},


			GoRyGl() {

				let options = {
					msg: '没有权限',
					type: 'danger'
				};
				this.$refs.toast.showTips(options);
			},

			addpersonnel() {


				this.$refs.buyerModel.open()
			},

		}
	}
</script>

<style lang="scss">
	@import "./Personnelmanagement.scss";
</style>